package com;

import java.util.Random;

public class co {

    public static void main(String[] args) {
        code(5);
        System.out.println("您的验证码为：");
        System.out.println(code(5));

    }

    public static String code(int n)
    {
        Random r=new Random();
        String cod="";
        for (int i=1;i<=n;i++)
        {
            int type=r.nextInt(3);
            switch (type)
        {
            case 0:
                cod+=r.nextInt(10);
                break;

            case 1:
                char ch1= (char) (r.nextInt(26)+65);
                cod+=ch1;
                break;
            case 2:
                char ch2= (char) (r.nextInt(26)+97);
                cod+=ch2;
                break;

        }
        }
       return cod;
    }
}
